package top.infopub.mgr.sts.service.impl;


import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.infopub.generic.GenericDao;
import top.infopub.generic.GenericServiceImpl;
import top.infopub.mgr.sts.dao.OrgSuperQaDao;
import top.infopub.mgr.sts.domain.QaConsoleDomain;
import top.infopub.mgr.sts.service.OrgSuperQaService;
import top.infopub.mgr.util.DateUtils;
import top.infopub.model.sts.OrgSuperQa;

import com.google.common.collect.Maps;


@Service
public class OrgSuperQaServiceImpl extends GenericServiceImpl<OrgSuperQa, String> implements OrgSuperQaService {

    @Autowired
    private OrgSuperQaDao orgSuperQaDao;

    @Override
    public GenericDao<OrgSuperQa, String> getDao() {
        return orgSuperQaDao;
    }

    @Override
    public List<QaConsoleDomain> selectQaConsoleByWhere(Date stsMonth, String hrOrgSuperId) {
        Map<String, Object> where = Maps.newHashMap();
        where.put("stsMonthStart", stsMonth);
        Date stsMonthEnd = DateUtils.getMonthEnd(stsMonth);
        where.put("stsMonthEnd", stsMonthEnd);
        where.put("hrOrgSuperId", hrOrgSuperId);
        return orgSuperQaDao.selectQaConsoleByWhere(where);
    }

    @Override
    public List<QaConsoleDomain> selectQaRateByWhere(Date stsMonth, String hrOrgSuperId) {
        Map<String, Object> where = Maps.newHashMap();
        where.put("stsMonthStart", stsMonth);
        Date stsMonthEnd = DateUtils.getMonthEnd(stsMonth);
        where.put("stsMonthEnd", stsMonthEnd);
        where.put("hrOrgSuperId", hrOrgSuperId);
        return orgSuperQaDao.selectQaRateByWhere(where);
    }

    @Override
    public List<QaConsoleDomain> selectQaAmountByWhere(Integer belongsYear, String hrOrgSuperId,
                                                       String aimType) {
        Map<String, Object> where = Maps.newHashMap();
        where.put("belongsYear", belongsYear);
        where.put("aimType", Integer.parseInt(aimType));
        where.put("hrOrgSuperId", hrOrgSuperId);
        return orgSuperQaDao.selectQaAmountByWhere(where);
    }
}